#ifndef __CAR_H
#define __CAR_H

#define BIN1_1(x)		GPIO_WriteBit(GPIOA, GPIO_Pin_4, (BitAction)(x))
#define BIN2_1(x)		GPIO_WriteBit(GPIOA, GPIO_Pin_5, (BitAction)(x))

#define AIN1_1(x)		GPIO_WriteBit(GPIOA, GPIO_Pin_8, (BitAction)(x))
#define AIN2_1(x)		GPIO_WriteBit(GPIOE, GPIO_Pin_13, (BitAction)(x))


#define BIN1_2(x)		GPIO_WriteBit(GPIOE, GPIO_Pin_7, (BitAction)(x))
#define BIN2_2(x)		GPIO_WriteBit(GPIOE, GPIO_Pin_8, (BitAction)(x))

#define AIN1_2(x)		GPIO_WriteBit(GPIOG, GPIO_Pin_0, (BitAction)(x))
#define AIN2_2(x)		GPIO_WriteBit(GPIOG, GPIO_Pin_1, (BitAction)(x))

extern int16_t TIM3_maichong,TIM5_maichong,TIM1_maichong,TIM4_maichong;
extern int16_t PWM_TIM5,PWM_TIM3,PWM_TIM1,PWM_TIM4;
extern float left_targetspeed;//左轮目标速度
extern float right_targetspeed;//右轮目标速度


extern float leftForward_targetspeed;//左前轮目标速度
extern float rightForward_targetspeed;//右前轮目标速度
extern float leftBackward_targetspeed;//左后轮目标速度
extern float rightBackward_targetspeed;//右后轮目标速度

extern float left_targetmaichong;
extern float right_targetmaichong;
extern float targetdistance;
extern float targetAngle;


extern float KP;
extern float KI;
extern float KD;

extern int32_t TIM3_leijimaichong;
extern int32_t TIM5_leijimaichong;
extern int32_t TIM1_leijimaichong;
extern int32_t TIM4_leijimaichong;
extern uint16_t setdistance_states;
extern uint16_t setAngle_states;//执行运动指定角度标志,置1执行,执行完自动恢复0

void car_init(void);
void PWM_car_Init(void);

void car_left_forward(void);//左轮向前
void car_left_backward(void);//左轮向后
void car_left_stop(void);//左轮停止
void car_right_forward(void);//右轮向前
void car_right_backward(void);//右轮向后
void car_right_stop(void);//右轮停止

void car_forward(void);//前进
void car_right(void);//右转
void car_left(void);//左转
void car_backward(void);//后退
void car_stop(void);//停止

void PWM_SetCompare1(uint16_t Compare);
void PWM_SetCompare2(uint16_t Compare);
void PWM_SetCompare3(uint16_t Compare);
void PWM_SetCompare4(uint16_t Compare);

//PWM的四个轮子的设定。
void PWM_SUM_SET(uint16_t leftCompare1,uint16_t leftCompare2,uint16_t rightCompare1,uint16_t rightCompare2);

//四个轮子单独pid控制
void set_left_forward_speed(float targetspeed);
void set_right_forward_speed(float targetspeed);
void set_left_backward_speed(float targetspeed);
void set_right_backward_speed(float targetspeed);
//左右各位一组进行合并控制pid
void set_left2_speed(float left_targetspeed);
void set_right2_speed(float right_targetspeed);
//总体进行控制4个

void set_speed2(float left_targetspeed_for,float left_targetspeed_back ,float right_targetspeed_for,float right_targetspeed_back);

//以下是之前留下来的代码：：：：
void set_distance(float targetdistance);
void set_Angle(float targetAngle1);

void set_left_speed(float left_targetspeed);
void set_right_speed(float right_targetspeed);
void set_speed(float left_targetspeed,float right_targetspeed);
#endif





